< previous page page_454 next page >

Page 454
After youve added this method to your Employee collection class, you need to perform one more step. Go to the Tools, Procedure Attributes menu item and select the Iterate() function from the drop-down list of names. Click the Advanced command button, and in the Procedure ID drop-down list, type in the value 4, as shown in Figure 22.6.
8160-0454a.gif
Figure 22.6
The Procedure Attributes dialog box.
This value is a special identifier that tells COM that this procedure ID is the iteration function that needs to be able to return the objects one by one from the collection. Now, via the Iterate 2 command button on the sample form, you can iterate through the collection using the For...Each Next construct:
9f31265bb40b592b1929e18a47ab28e5.gif
Private Sub cmdIterate2_Click()
   Dim oEmp As Employee

   lstNames.Clear
   For Each oEmp In moEmps
      lstNames.AddItem oEmp.LastName & ", " & _
                         oEmp.FirstName
   Next
End Sub

 
< previous page page_454 next page >

If you like this book, buy it!